<?php

class ImageAlbumController extends Controller
{
    private $model;
    function __construct()
    {
        $this->loadLibrary('Utility');
        $this->loadLibrary('Session');
        $this->model = $this->loadModel('imagealbum');
        parent::__construct();
    }

    public function index()
    {
        //var_dump($_SERVER);
        $albums = $this->model->getAlbumList();
        //var_dump($albums);
        $data['current_page'] = 'gallery';
        $view = $this->loadView('album');
        $view->setTplConfig('master', array('master/master2.html','general'));
        $view->appendBlockData(array('albums'=>$albums));
        $view->setBlockData("Album ảnh","title");
        $view->setBlockData($data,'menu');
//        var_dump($view);exit();
        $view->render();
    }

    public function detail($id=null)
    {
        if (!isset($id) || $id=='')
        {
            Utility::redirect("imagealbum/index");
            return;
        }

        setcookie('albumid', $id, null, '/');
        header('Location: '.Utility::websiteRoot().'/public/gallery/index.html');
    }
}

